#ifndef VERTEX_ATTRIBUTES_H
#define VERTEX_ATTRIBUTES_H

#include "GlobalDefines.hpp"

const enum VertexAttr
{
    Position = 0,
    Color,
    Normal,
    Texcoord,
    Alpha,
    Material,
    Tangent,
    Intensity,
	  Bitangent
};

/*
 * VertexElement
 */
struct VertexElement
{
    VertexElement(VertexAttr vert_attrib, GLenum vert_type, GLint vert_size, GLint vert_offset):
        attr(vert_attrib), type(vert_type), size(vert_size),  offset(vert_offset) {}

    VertexAttr attr;
    GLenum type;    
    GLint size;
    GLint offset;
};

/*
 * VertexDecl
 */
class VertexDecl
{
public:    
    VertexDecl() {}

    void AddElement(const VertexElement& element)
    {
        elements.push_back(element);
    }

    std::vector<VertexElement> GetElements()
    {
        return elements;
    }

    bool skip()
    {
        return false;
    }

private:
    std::vector<VertexElement> elements;

};

/*
 * Default vertex declarations
 */

//
// PositionTextureVertex
// vPosition: 3 * GL_FLOAT    = 12
// vTexcoord: 2 * GL_FLOAT    = 8
// ------------------------------------
//                      total = 20bytes

class PositionTextureVertexDecl : public VertexDecl
{
public:
    PositionTextureVertexDecl()
    {
        AddElement(VertexElement(Position, GL_FLOAT, 3, 0));
        AddElement(VertexElement(Texcoord, GL_FLOAT, 2, 12));
    }
};

//
// PositionTextureNormalVertex
// vPosition: 3 * GL_FLOAT    = 12
// vTexcoord: 2 * GL_FLOAT    = 8
// vNormal:   3 * GL_FLOAT    = 12
// ------------------------------------
//                      total = 32bytes

class PositionTextureNormalVertexDecl : public VertexDecl
{
public:
    PositionTextureNormalVertexDecl()
    {
        AddElement(VertexElement(Position, GL_FLOAT, 3, 0));
        AddElement(VertexElement(Texcoord, GL_FLOAT, 2, 12));
        AddElement(VertexElement(Normal,   GL_FLOAT, 3, 20));
    }
};


#endif